<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<title>Android WebView 与 Javascript 交互</title>
<head>
	<style>
			body {
				background-color: #e6e6e6
			}

			.rect {
				color: white;
				font-family: Verdana, Arial, Helvetica, sans-serif;
				font-size: 16px;
				width: 100px;
				padding: 6px;
				background-color: #98bf21;
				text-decoration: none;
				text-align: center;
				border: none;
				cursor: pointer;
			}

			.inputStyle {
				font-size: 16px;
				padding: 6px
			}
		</style>
</head>

<body>
<p>测试Android WebView 与 Javascript 交互</p> <input id="name_input" class="inputStyle" type="text" />
<a class="rect" onclick="sendInfoToJava()">JS调用Java</a>
<div> <img id="imgpic" style="width: 200px; height: 150px; background-color: #98bf21;" onclick="getPic()"/> </div> <input style="width: 200px;" value="点击img标签调用相册" />
<div> <img id="imgcam" style="width: 200px; height: 150px; background-color: #98bf21;" onclick="openCamera()" /> </div> <input style="width: 200px;" value="点击img标签调用相机" />
<script>
			function sendInfoToJava() {
				//调用android程序中的方法，并传递参数
				var name = document.getElementById("name_input").value;
				window.AndroidWebView.showInfoFromJs(name);
			}

			function getPic() {
				//打开图片选择器
				window.AndroidWebView.getPic();
			}

			function openCamera() {
				//打开相机
				window.AndroidWebView.openCamera();
			}
			//在android代码中调用此方法
			function showInfoFromJava(msg) {
				alert("来自客户端的信息：" + msg);
			}
			function setImage(path){
                document.getElementById("imgpic").src = path;
                alert(path);
            }
            function setImgCamera(path){
                document.getElementById("imgcam").src = path;
                alert(path);
            }
</script>
</body>

</html>